package app.myproject.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import app.myproject.model.NotificationVO;

public class NotificationValidator implements Validator {

	@Override
	public boolean supports(Class clazz) {
		//just validate the Notification instances
		return NotificationVO.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		// Check Name
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name",	"required.name", "Name is required.");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "url",	"required.name", "URL is required.");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description",	"required.name", "Description is required.");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email",	"required.name", "Email is required.");

	}

}
